package com.zhage.service;

import com.zhage.dao.StudentRepository;
import com.zhage.domain.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {

    @Autowired
    StudentRepository studentRepository;

    /*
    * 读取所以学生的数据
    * */
    public List<Student> findAll(){
        return studentRepository.findAll();
    }


    /**
     * 插入学生
     * @param stu
     * @return
     */
    public Student insert(Student stu){
        return studentRepository.save(stu);
    }

    /**
     * 更新学生
     * @param stu
     * @return
     */
    public Student update(Student stu){
        return studentRepository.save(stu);
    }
}
